package com.ruoyi.system.controller;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.LhkCustomer;
import com.ruoyi.system.domain.LhkOrders;
import com.ruoyi.system.service.ILhkOrdersService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.LhkReservation;
import com.ruoyi.system.service.ILhkReservationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 酒店预约管理Controller
 * 
 * @author fzb
 * @date 2025-05-29
 */
@RestController
@RequestMapping("/system/hotel_reservation")
public class LhkReservationController extends BaseController
{
    @Autowired
    private ILhkReservationService lhkReservationService;

    @Autowired
    private ILhkOrdersService lhkOrdersService;

    @PostMapping("/addOrder")
    public AjaxResult addOrder(@RequestBody Map<String, Object> lhkOrders) {
        int insertinformation = lhkReservationService.insertinformation(lhkOrders);
        // 调用服务层方法添加订单
    return success();
    }

    /**
     * 查询酒店预约管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_reservation:list')")
    @GetMapping("/list")
    public TableDataInfo list(LhkReservation lhkReservation) {
        startPage();
        List<LhkReservation> list = lhkReservationService.selectLhkReservationList(lhkReservation);
        System.out.println(list);
        return getDataTable(list);
    }

    /**
     * 导出酒店预约管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_reservation:export')")
    @Log(title = "酒店预约管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LhkReservation lhkReservation)
    {
        List<LhkReservation> list = lhkReservationService.selectLhkReservationList(lhkReservation);
        ExcelUtil<LhkReservation> util = new ExcelUtil<LhkReservation>(LhkReservation.class);
        util.exportExcel(response, list, "酒店预约管理数据");
    }

    /**
     * 获取酒店预约管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_reservation:query')")
    @GetMapping(value = "/{reservationId}")
    public AjaxResult getInfo(@PathVariable("reservationId") Long reservationId)
    {
        return success(lhkReservationService.selectLhkReservationByReservationId(reservationId));
    }

    /**
     * 新增酒店预约管理
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_reservation:add')")
    @Log(title = "酒店预约管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LhkReservation lhkReservation)
    {
        LhkCustomer lhkCustomer = new LhkCustomer();
        return toAjax(lhkReservationService.insertLhkReservation(lhkReservation, lhkCustomer));
    }

    /**
     * 修改酒店预约管理
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_reservation:edit')")
    @Log(title = "酒店预约管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LhkReservation lhkReservation)
    {
        return toAjax(lhkReservationService.updateLhkReservation(lhkReservation));
    }

    /**
     * 删除酒店预约管理
     */
    @PreAuthorize("@ss.hasPermi('system:hotel_reservation:remove')")
    @Log(title = "酒店预约管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reservationIds}")
    public AjaxResult remove(@PathVariable Long[] reservationIds)
    {
        return toAjax(lhkReservationService.deleteLhkReservationByReservationIds(reservationIds));
    }
}
